<?php

class Dom extends DOMDocument {

    /**
     *
     * @var DOMXPath
     */
    public $xpath = null;

    public function __construct($version = null, $encoding = null, $source = null) {
        parent::__construct($version, $encoding);
        if ($source != null) {
            libxml_use_internal_errors(true);
            $this->loadHTML($source);
            $this->xpath = new DOMXpath($this);
        }
    }

}

class NObject {
    
    private $data = null;
    public function __construct($data) {
        $this->data = $data;
    }
    public function getAttribute($name) {
        return isset($this->data[$name]) ? $this->data[$name] : null;
    }
    
    public function hasAttribute($name) {
        return isset($this->data[$name]);
    }
    
    public function __get($name) {
        return isset($this->data[$name]) ? $this->data[$name] : null;
    }
}

class NList implements Iterator{

    protected $_list = null;
    private $position = 0;

    public function __construct($data) {
        $this->_list = $data;
        $this->position = 0;
    }

    

    function rewind() {
        $this->position = 0;
    }

    function current() {

        return $this->_list[$this->position];
    }

    function key() {
        return $this->position;
    }

    function next() {
        ++$this->position;
    }

    function valid() {
        return isset($this->_list[$this->position]);
    }

}
